import 'package:flutter/material.dart';
import 'package:im_flutter_sdk/im_flutter_sdk.dart';
import 'package:qunaimedical/components/custom_video_player.dart';
import 'package:qunaimedical/im/chat/video_thumb.dart';
import 'package:video_thumbnail/video_thumbnail.dart';

class ChatVideoBubble extends StatelessWidget {
  ChatVideoBubble(this.body);

  final EMVideoMessageBody body;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100,
      width: 100,
      child: InkWell(
        child: GenThumbnailImage(
          thumbnailRequest: ThumbnailRequest(
              video: body.thumbnailRemotePath == null ||
                      body.thumbnailRemotePath == ''
                  ? body.localPath
                  : body.thumbnailRemotePath,
              thumbnailPath: null,
              imageFormat: ImageFormat.JPEG,
              maxHeight: 200,
              maxWidth: 200,
              timeMs: 0,
              quality: 50),
        ),
        onTap: () {
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (c) => CustomVideoPlayer(
                body.thumbnailRemotePath == null ||
                        body.thumbnailRemotePath == ''
                    ? body.localPath
                    : body.thumbnailRemotePath,
                isLocalFile: body.thumbnailRemotePath == null ||
                    body.thumbnailRemotePath == '',
              ),
            ),
          );
        },
      ),
    );
  }
}
